package eSignDemo

import (
	"context"
	"github.com/renxingcode/esign-go-sdk"
	"github.com/zeromicro/go-zero/core/logx"
	"gozero-demo/internal/svc"
	"gozero-demo/internal/types"
)

type GetESignTemplateDetailLogic struct {
	logx.Logger
	ctx      context.Context
	svcCtx   *svc.ServiceContext
	eSignSdk *esign.Client
}

// 获取流程模版详情
func NewGetESignTemplateDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetESignTemplateDetailLogic {
	return &GetESignTemplateDetailLogic{
		Logger:   logx.WithContext(ctx),
		ctx:      ctx,
		svcCtx:   svcCtx,
		eSignSdk: svcCtx.ESignSdk,
	}
}

func (l *GetESignTemplateDetailLogic) GetESignTemplateDetail(req *types.GetESignTemplateDetailRequest) (resp *types.CommonResponse, err error) {
	templateDetail, err := l.eSignSdk.Template.GetESignTemplateDetail(req.ESignTemplateId, true, req.WriteLog)
	if err != nil {
		return nil, err
	}
	return types.SuccessResponse(templateDetail, l.ctx), nil
}
